-
-
Notifications
You must be signed in to change notification settings - Fork 102
Fixes quotation marks in titles on /transfer #1332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
||
String generateTitle(String originalMessage) { | ||
String chatGptTitleRequest = | ||
"Summarize the following question into a concise title or heading not more than 5 words, remove quotations if any: %s" | ||
.formatted(originalMessage); | ||
Optional<String> chatGptTitle = chatGptService.ask(chatGptTitleRequest, null); | ||
String title = chatGptTitle.orElse(createTitle(originalMessage)); | ||
|
||
// 🔧 FIX: Remove surrounding quotes | ||
title = title.replaceAll("^\"|\"$", ""); | ||
|
||
if (title.length() > TITLE_MAX_LENGTH) { | ||
title = title.substring(0, TITLE_MAX_LENGTH); | ||
} | ||
|
||
return title; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a leftover or something? that new method isnt used anywhere. remove it or use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, yes my bad i will find a cleaner fix. Pardon my mistakes im new to contributing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries, here to help :)
.formatted(originalMessage); | ||
Optional<String> chatGptTitle = chatGptService.ask(chatGptTitleRequest, null); | ||
String title = chatGptTitle.orElse(createTitle(originalMessage)); | ||
title = title.replaceAll("^[\"']|[\"']$", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please chain it instead.
title = title.replaceAll("^[\"']|[\"']$", ""); | |
String title = chatGptTitle.orElse(createTitle(originalMessage)) | |
.replaceAll("^[\"']|[\"']$", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not a fan of your regex for two reasons:
- currently it also triggers when just one condition is met, for example
Need help with "foo"
or"Foo" is weird
, it shouldnt trigger here. Only for"Foo bar"
. - if we do the first part then regex is overkill for this
so i propose to instead add if (title.startsWith("\"") && title.endsWith("\"")) { title = title.substring(1, title.length() - 1); }
or something like that.
that said, i dont have a strong opinion on avoiding regex here specifically, so whatever. but please fix the first part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok im on it. Thanks for the guidance.
event.getGuild()) | ||
.and(sendMessageToTransferrer.apply(createdForumPost))) | ||
event.getGuild()).and(sendMessageToTransferrer.apply(createdForumPost))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you didnt change anything here. i wouldnt be surprised if this will be auto-reverted the second you run spotless
Added a regex to remove the quotation marks in the begging and in the end of the title (single or double).
Fixes and closes #1134